package com.quick.job;

import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @author wangxin86
 * @title: TestJob
 * @description: TODO
 * @date 2019/7/29 15:48
 */
@Component(value = "testJob")
@Slf4j
public class TestJob implements SimpleJob {
    @Override
    public void execute(ShardingContext shardingContext) {
        System.out.println("test");
        log.info(String.format("----任务[%s] 开始执行--Thread ID: %s, 总片数: %s, " +
                        "当前分片: %s,当前分片参数: %s,"   ,
                //获取当前的任务名称
                shardingContext.getJobName(),
                //获取当前线程的id
                Thread.currentThread().getId(),
                //获取任务总片数
                shardingContext.getShardingTotalCount(),
                //获取当前分片项
                shardingContext.getShardingItem(),
                //获取当前的参数
                shardingContext.getShardingParameter()
        ));
        log.info("start");
    }
}
